package com.example.demo.service.redis;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * Created by User on 2017/9/14.
 */

@Service("RedisTemplateImpl")
public class RedisTemplateImpl implements IRedisService {

    private static final Logger log = LoggerFactory.getLogger(RedisTemplateImpl.class);
    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public void set(String key, String value) {
        redisTemplate.opsForValue().set(key, value);
    }

    @Override
    public String get(String key) {
        Object value = redisTemplate.opsForValue().get(key);
        if (value instanceof String)
            return (String)value;
        else
            return null;
    }
}
